<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户开户银行账号信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
		<form id="cust_cst_np_bank_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_50">
                    <div class="label">开户银行</div>
                    <div class="field">
                        <select name="bkCd" id="bkCd" data-value="" validate="{required:true, select: true}">
                             <c:forEach items="${searchSelectBkCdList }" var="kv" begin="0" step="1" varStatus="status">
								<c:if test="${status.index == 0}">
									<option value="${kv.key }" checked >${kv.value }</option>
								</c:if>
								<c:if test="${status.index != 0}">
									<option value="${kv.key }">${kv.value }</option>
								</c:if>
							 </c:forEach>
                        </select>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">开户机构</div>
                    <div class="field">
                        <input name="accOrgNm" id="accOrgNm" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:60}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">开户名称</div>
                    <div class="field">
                        <input name="accNm" id="accNm" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:30}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">开户行行号</div>
                    <div class="field">
                        <input name="bkNo" id="bkNo" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:30}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">银行账号</div>
                    <div class="field">
                        <input name="accNo" id="accNo" type="text" class="ui-textbox" value="" validate="{required:true,number:true, maxlength:30}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
			        <div class="label">账户类型</div>
			          <div class="field">
			         	 <select name="accTypCd" id="accTypCd" data-value="" validate="{required:true, select: true}">
			            	<c:forEach items="${searchSelectAccTypCdList }" var="kv" begin="0" step="1" varStatus="status">
								<c:if test="${status.index == 0}">
								     <option value="${kv.key }" checked >${kv.value }</option>
								</c:if>
							<c:if test="${status.index != 0}">
								    <option value="${kv.key }">${kv.value }</option>
								</c:if>
							</c:forEach>
			             </select>
			             <span class="requiredSymbol">*</span>
			         </div>
			    </div>
			    <div class="fieldBox col_50" id="div_certtypcd_id">
			        <div class="label">证件类型</div>
			          <div class="field">
			         	 <select name="certTypCd" id="certTypCd" data-value="" validate="{required:true, select: true}">
			            	<c:forEach items="${searchSelectCertTypCdList }" var="kv" begin="0" step="1" varStatus="status">
								<c:if test="${status.index == 0}">
								     <option value="${kv.key }" checked >${kv.value }</option>
								</c:if>
							<c:if test="${status.index != 0}">
								    <option value="${kv.key }">${kv.value }</option>
								</c:if>
							</c:forEach>
			             </select>
			             <span class="requiredSymbol">*</span>
			         </div>
			    </div>
                <div class="fieldBox col_50" id="div_certno_id">
                    <div class="label">证件号</div>
                    <div class="field">
                        <input name="certNo" id="certNo" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:30}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50" id="div_certno_id">
                    <div class="label">手机号</div>
                    <div class="field">
                        <input name="cardTel" id="cardTel" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:11}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <!-- <div class="fieldBox col_50">
                    <div class="label">是否代扣卡</div>
                    <div class="field">
					<c:forEach items="${searchSelectYesOrNoList }" var="kv" begin="0" step="1" varStatus="status">
	           			<c:if test="${kv.key == 0}">
	           				<input type="radio" value="${kv.key }" name="isDeduct" id="isDeductYes" checked />${kv.value }	
	           			</c:if>
	        	    	<c:if test="${kv.key != 0}">
	                       	<input type="radio" value="${kv.key }" name="isDeduct" id="isDeductNo"/>${kv.value }	
	                    </c:if>
	   				 </c:forEach>
	                 </div>
                </div> -->
                
                 <!--<div class="fieldBox col_50">
                    <div class="label">是否缺省代扣卡</div>
                    <div class="field">
					<c:forEach items="${searchSelectDefYesOrNoList }" var="kv" begin="0" step="1" varStatus="status">
	           				<c:if test="${status.index == 0}">
	           					<input type="radio" value="${kv.key }" name="isDefDeduct" id="isDefDeductNo" checked />${kv.value }	
	           				</c:if>
	        	    			<c:if test="${status.index != 0}">
	                       		<input type="radio" value="${kv.key }" name="isDefDeduct" id="isDefDeductYes"/>${kv.value }	
	                       	</c:if>
	   				 </c:forEach>
	                 </div>
                </div>-->
                 <!-- <div class="fieldBox col_50">
                     <div class="label">附件上传</div>
                     <div class="field">
                        <input name="equPropPct" id="equPropPct" type="text" class="ui-textbox" value="" readonly>
                     </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">状态</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="audStsCd" id="audStsCd" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:200}"></textarea>
                    </div>
                </div> -->
                <!-- hide data -->
		        <div class="fieldBox col_100" style="display:none;">
		          <div class="field">
		              <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
		              <input name="cbId" id="cbId" type="text" class="ui-textbox" value="${cbId}">
		          </div>
		        </div>
            </div>
        </form>
	<script>
		$(function() {
		   $("#cust_cst_np_bank_form").ligerForm({
                validate: true
           });
	       initData();
		});
		
		//定义父级调用事件
		frameElement.dialog.onOk = function () {
			save();
		}
		
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		//保存
		var cstBankAddUrl = "<%=path%>/customer/cstbank/add.do";
		var cstBankModifyUrl = "<%=path%>/customer/cstbank/modify.do";
		function save(){
			var ligerForm = liger.get("cust_cst_np_bank_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var isDeduct = $('input[name="isDeduct"]:checked ').val();
            data["isDeduct"] = isDeduct;
            //var isDefDeduct = $('input[name="isDefDeduct"]:checked ').val();//暂时和是否划扣卡相同
            data["isDefDeduct"] = isDeduct;
            var cbId = $("#cbId").val();
            var url = cstBankAddUrl;
            if(cbId != ""){
            	url = cstBankModifyUrl;
            	data["id"]= cbId;
            }
            //设置客户ID
            var cstId = $("#cstId").val();
            data["cstId"]= cstId;
            AjaxUtils.ajaxPost(url, data, addCallback);
		}
		
		
		//新增回调
		function addCallback(msg){
			var cstId = $("#cstId").val();
			if(msg.success == 1){
				 UIUtils.alertSuccess(msg.info);
				 parent.cstBankGrid.setParm("cstId",cstId);
				 parent.cstBankGrid.reload();
				 frameElement.dialog.close();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改初始化数据
		function initData(){
			var cbId = $("#cbId").val();
	    	if(!cbId){
	    		//默认数据
	    		var form = new liger.get("cust_cst_np_bank_form");
	    		form.setData({
		    		certTypCd:'${certTypCd}',
		    		certNo:'${certNo}',
		    		bkCd:CustomerConstant.CST_BK_CD_POST
		    	});
	    		return;
	    	}
	    	var _url = '<%=path%>/customer/cstbank/getById.do';
	    	AjaxUtils.ajaxGet(_url, {id:cbId}, initCallback);
    	}
		
		//初始化回调
		function initCallback(msg){
			if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改时候设置页面数据
	    function setData(data){
	    	var form = new liger.get("cust_cst_np_bank_form");
	    	$("input[name=isDeduct][value='"+data.isDeduct+"']").prev().click();
	    	$("input[name=isDefDeduct][value='"+data.isDefDeduct+"']").prev().click();
	    	form.setData({
	    		bkCd:data.bkCd,
	    		accOrgNm:data.accOrgNm,
	    		accNm:data.accNm,
	    		accNo:data.accNo,
	    		bkNo:data.bkNo,
	    		accTypCd:data.accTypCd,
	    		certTypCd:data.certTypCd,
	    		certNo:data.certNo,
	    		cardTel:data.cardTel,
	    	});
		};
		
	</script>

</body>
</html>